package com.huluobo.a2109kotlinshopping.order

import android.util.Log
import androidx.recyclerview.widget.LinearLayoutManager
import com.huluobo.a2109kotlinshopping.R
import com.huluobo.a2109kotlinshopping.base.BaseMVVMActivity
import com.huluobo.a2109kotlinshopping.databinding.ActivityOrderBinding
import com.huluobo.a2109kotlinshopping.db.DatabaseUtil

class OrderPayActivity : BaseMVVMActivity<ActivityOrderBinding>() {
    lateinit var adapter: OrderPayAdapter
    private val orderList = mutableListOf<OrderPayBean>()
    override fun initData() {
        val queryOrderPayList = DatabaseUtil.getDb().orderPayDao().queryOrderPayList()
        Log.i("TagA", "已付款订单:${queryOrderPayList.size}")
        orderList.addAll(queryOrderPayList)
        adapter.notifyDataSetChanged()
    }

    override fun initView() {
        //修改头布局
        dataBinding.orderHeader.headerTitle.text = "已付款"
        dataBinding.orderHeader.back.setOnClickListener { finish() }

        dataBinding.orderPayRv.layoutManager = LinearLayoutManager(this)
        adapter = OrderPayAdapter(orderList)
        dataBinding.orderPayRv.adapter = adapter
    }

    override fun getLayoutId(): Int = R.layout.activity_order
}